package com.example.redisstudy.distributedLock_diy.controller;

import com.example.redisstudy.distributedLock_diy.utils.ILock;
import com.example.redisstudy.redisCache.domain.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <pre>
 * 功能描述：
 * </pre>
 *
 * @author: 李明杰
 * @date: 2022/6/24 19:20
 */
@RestController
@RequestMapping("/redis")
public class SimpleRedisLockController {
    @Resource
    ILock iLock;

    @GetMapping("/lock")
    public Result testLock() {
        return Result.ok(iLock.tryLock(20));
    }

    @GetMapping("/unlock")
    public Result testUnLock() {
        iLock.unlock();
        return Result.ok();
    }

}
